% test_DataSet

%%

clear classes
clc

%% Load the Matlab built-in 'iris' dataset into @DataMatrix object

% iris.dat
%   1. sepal length in cm
%   2. sepal width in cm
%   3. petal length in cm
%   4. petal width in cm
%   5. class: 
%      -- Iris Setosa
%      -- Iris Versicolour
%      -- Iris Virginica

load iris.dat
zFetName = {'sepal_length', 'sepal_width', 'petal_length', 'petal_width'};
zLabName = {'iris_setosa', 'iris_versicolour', 'iris_virginica'};

X = iris(:, 1:4)/10;

Y = -ones(150, 3);
Y(  1: 50, 1) = 1;
Y( 51:100, 2) = 1;
Y(101:150, 3) = 1;

zRowName = {''};
zColName = zFetName;
dmX = DataMatrix('iris_X', X, zRowName, zColName);
% dmX.showHead();

zRowName = {''};
zColName = zLabName;
dmY = DataMatrix('iris_Y', Y, zRowName, zColName);
% dmY.showHead();

%% Test @DataSet::construct

ds = DataSet('iris', dmX, dmY);

%% Test Gets

[nObs, nFet, nLab] = ds.getSize(); % 150, 4, 3

X = ds.getXMat();
Y = ds.getYMat();

zObsName = ds.getZObsName();
isequal(zObsName, ds.getZObsName(':')); % >> true
zObsName = ds.getZObsName(1:2);

zFetName = ds.getZFetName();
isequal(zFetName, ds.getZFetName(':')); % >> true
zFetName = ds.getZFetName(1:2);

zLabName = ds.getZLabName();
isequal(zLabName, ds.getZLabName(':')); % >> true
zLabName = ds.getZLabName();

%% Test Sets

ds.setZObsName(':', {'o'});
ds.setZObsName(1:2, {'obs_1', 'obs_2'});
ds.setZObsName(1:2);
ds.setZObsName();

ds.setZFetName(1:2);
ds.setZFetName();
ds.setZFetName(1:2, ...
    {'sepal_length', ...
    'sepal_width'});
ds.setZFetName(':', ...
    {'sepal_length', ...
    'sepal_width', ...
    'petal_length', ...
    'petal_width'});

ds.setZLabName(1:2);
ds.setZLabName();
ds.setZLabName(1:2, ...
    {'iris_setosa', ...
    'iris_versicolour'});
ds.setZLabName(':', ...
    {'iris_setosa', ...
    'iris_versicolour', ...
    'iris_virginica'});

%% Test @DataSet::clone

ds2 = ds.clone();

%% Test @DataSet::duplicate

ds3 = DataSet();
ds3.duplicate(ds);

%% Test @DataSet::empty

ds2.empty();
